package edu.gatech.cs2340.OregonTrail;

import javax.imageio.ImageIO;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import java.awt.GridBagLayout;
import javax.swing.JTextField;
import java.awt.Component;
import java.awt.Graphics;
import java.awt.GridBagConstraints;
import java.awt.Image;
import java.awt.Insets;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseListener;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import javax.swing.JLabel;
import edu.gatech.cs2340.OregonTrail.EventSystem.AtShopEvent;
import edu.gatech.cs2340.OregonTrail.EventSystem.CommCoordinator;
import edu.gatech.cs2340.OregonTrail.EventSystem.GUIEvent;
import edu.gatech.cs2340.OregonTrail.EventSystem.GUIListener;
import edu.gatech.cs2340.OregonTrail.EventSystem.PlayerInventoryModifiedEvent;
import java.awt.Dimension;
import java.io.IOException;
import java.awt.Font;
import java.awt.Color;
import javax.swing.SwingConstants;
import javax.swing.ImageIcon;

import java.awt.event.MouseEvent;

public class ShopPanel extends JPanel implements GUIListener, ActionListener, MouseListener{

	private static final long serialVersionUID = 1L;
	
	private JTextField foodTF;
	private JTextField oxenTF;
	private JTextField clothingTF;
	private JTextField roundsTF;
	private JLabel foodLabel;
	private JTextField wheelTF;
	private JTextField axleTF;
	private JTextField tongueTF;
	private JLabel titleLabel;
	private JLabel oxenLabel;
	private JLabel clothingLabel;
	private JLabel ammoLabel;
	private JLabel wheelLabel;
	private JLabel axleLabel;
	private JLabel tongueLabel;
	private JLabel foodPriceLabel;
	private JLabel oxenPriceLabel;
	private JLabel clothingPriceLabel;
	private JLabel ammoPriceLabel;
	private JLabel wheelPriceLabel;
	private JLabel axlePriceLabel;
	private JLabel tonguePriceLabel;
	private Shop shop;
	private OregonTrailApp parent;
	private CommCoordinator communicator;
	private JLabel purchaseButton;
	private JLabel currMoneyLabel;
	private JLabel currWeightLabel;
	private JLabel foodWeightLabel;
	private JLabel oxenWeightLabel;
	private JLabel clothingWeightLabel;
	private JLabel ammoWeightLabel;
	private JLabel tongueWeightLabel;
	private JLabel axleWeightLabel;
	private JLabel wheelWeightLabel;
	private JLabel playerFoodStock;
	private JLabel playerOxenStock;
	private JLabel playerClothingStock;
	private JLabel playerAmmoStock;
	private JLabel lblYourStock;
	private JLabel lblQuantity;
	private JLabel lblItem;
	private JLabel lblPrice;
	private JLabel lblWeight;
	private JLabel lblShopStock;
	private JLabel shopFoodStock;
	private JLabel shopOxenStock;
	private JLabel shopClothingStock;
	private JLabel shopAmmoStock;
	private JLabel shopWheelStock;
	private JLabel shopAxleStock;
	private JLabel shopTongueStock;
	private JLabel finishButton;
	private Image backgroundImage;
	private JLabel playerWheelStock;
	private JLabel playerTongueStock;
	private JLabel playerAxleStock;

	/**
	 * Create the panel.
	 * @throws IOException 
	 */
	public ShopPanel(OregonTrailApp parent, CommCoordinator comm) throws IOException {
		this.parent = parent;
		communicator = comm;
		communicator.AddGUIListener(this);
		backgroundImage = ImageIO.read(PlayPanel.class.getResource("/edu/gatech/cs2340/OregonTrail/Images/shopBackground.png"));
		setPreferredSize(new Dimension(524, 600));
		GridBagLayout gridBagLayout = new GridBagLayout();
		gridBagLayout.columnWidths = new int[]{60, 65, 55, 100, 40, 45, 75, 60, 0};
		gridBagLayout.rowHeights = new int[]{25, 25, 50, 25, 30, 35, 35, 35, 35, 35, 35, 35, 35, 45, 70, 0};
		gridBagLayout.columnWeights = new double[]{0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, Double.MIN_VALUE};
		gridBagLayout.rowWeights = new double[]{0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, Double.MIN_VALUE};
		setLayout(gridBagLayout);
		
		titleLabel = new JLabel("Welcome to the shop!");
		titleLabel.setBackground(Color.WHITE);
		titleLabel.setForeground(Color.BLACK);
		titleLabel.setFont(new Font("Tahoma", Font.BOLD, 15));
		GridBagConstraints gbc_titleLabel = new GridBagConstraints();
		gbc_titleLabel.anchor = GridBagConstraints.NORTH;
		gbc_titleLabel.insets = new Insets(0, 0, 5, 0);
		gbc_titleLabel.gridwidth = 8;
		gbc_titleLabel.gridx = 0;
		gbc_titleLabel.gridy = 1;
		add(titleLabel, gbc_titleLabel);
		
		currWeightLabel = new JLabel("Current Total Weight: 0 / 3500");
		currWeightLabel.setBackground(new Color(238, 232, 170));
		currWeightLabel.setOpaque(true);
		GridBagConstraints gbc_currWeightLabel = new GridBagConstraints();
		gbc_currWeightLabel.fill = GridBagConstraints.BOTH;
		gbc_currWeightLabel.insets = new Insets(0, 0, 5, 5);
		gbc_currWeightLabel.gridwidth = 3;
		gbc_currWeightLabel.gridx = 1;
		gbc_currWeightLabel.gridy = 3;
		add(currWeightLabel, gbc_currWeightLabel);
		
		currMoneyLabel = new JLabel("Current Funds: $0");
		currMoneyLabel.setBackground(new Color(238, 232, 170));
		currMoneyLabel.setOpaque(true);
		GridBagConstraints gbc_currMoneyLabel = new GridBagConstraints();
		gbc_currMoneyLabel.fill = GridBagConstraints.BOTH;
		gbc_currMoneyLabel.insets = new Insets(0, 0, 5, 5);
		gbc_currMoneyLabel.gridwidth = 3;
		gbc_currMoneyLabel.gridx = 4;
		gbc_currMoneyLabel.gridy = 3;
		add(currMoneyLabel, gbc_currMoneyLabel);
		
		lblYourStock = new JLabel("Your stock");
		lblYourStock.setHorizontalAlignment(SwingConstants.CENTER);
		lblYourStock.setBackground(new Color(238, 232, 170));
		lblYourStock.setOpaque(true);
		GridBagConstraints gbc_lblYourStock = new GridBagConstraints();
		gbc_lblYourStock.fill = GridBagConstraints.BOTH;
		gbc_lblYourStock.insets = new Insets(0, 0, 5, 5);
		gbc_lblYourStock.gridx = 1;
		gbc_lblYourStock.gridy = 5;
		add(lblYourStock, gbc_lblYourStock);
		
		lblQuantity = new JLabel("Quantity");
		lblQuantity.setHorizontalAlignment(SwingConstants.CENTER);
		lblQuantity.setBackground(new Color(238, 232, 170));
		lblQuantity.setOpaque(true);
		GridBagConstraints gbc_lblQuantity = new GridBagConstraints();
		gbc_lblQuantity.fill = GridBagConstraints.BOTH;
		gbc_lblQuantity.insets = new Insets(0, 0, 5, 5);
		gbc_lblQuantity.gridx = 2;
		gbc_lblQuantity.gridy = 5;
		add(lblQuantity, gbc_lblQuantity);
		
		lblItem = new JLabel("Item");
		lblItem.setHorizontalAlignment(SwingConstants.CENTER);
		lblItem.setBackground(new Color(238, 232, 170));
		lblItem.setOpaque(true);
		GridBagConstraints gbc_lblItem = new GridBagConstraints();
		gbc_lblItem.fill = GridBagConstraints.BOTH;
		gbc_lblItem.insets = new Insets(0, 0, 5, 5);
		gbc_lblItem.gridx = 3;
		gbc_lblItem.gridy = 5;
		add(lblItem, gbc_lblItem);
		
		lblPrice = new JLabel("Price");
		lblPrice.setHorizontalAlignment(SwingConstants.CENTER);
		lblPrice.setBackground(new Color(238, 232, 170));
		lblPrice.setOpaque(true);
		GridBagConstraints gbc_lblPrice = new GridBagConstraints();
		gbc_lblPrice.fill = GridBagConstraints.BOTH;
		gbc_lblPrice.insets = new Insets(0, 0, 5, 5);
		gbc_lblPrice.gridx = 4;
		gbc_lblPrice.gridy = 5;
		add(lblPrice, gbc_lblPrice);
		
		lblWeight = new JLabel("Weight");
		lblWeight.setHorizontalAlignment(SwingConstants.CENTER);
		lblWeight.setBackground(new Color(238, 232, 170));
		lblWeight.setOpaque(true);
		GridBagConstraints gbc_lblWeight = new GridBagConstraints();
		gbc_lblWeight.fill = GridBagConstraints.BOTH;
		gbc_lblWeight.insets = new Insets(0, 0, 5, 5);
		gbc_lblWeight.gridx = 5;
		gbc_lblWeight.gridy = 5;
		add(lblWeight, gbc_lblWeight);
		
		lblShopStock = new JLabel("Shop Stock");
		lblShopStock.setHorizontalAlignment(SwingConstants.CENTER);
		lblShopStock.setBackground(new Color(238, 232, 170));
		lblShopStock.setOpaque(true);
		GridBagConstraints gbc_lblShopStock = new GridBagConstraints();
		gbc_lblShopStock.fill = GridBagConstraints.BOTH;
		gbc_lblShopStock.insets = new Insets(0, 0, 5, 5);
		gbc_lblShopStock.gridx = 6;
		gbc_lblShopStock.gridy = 5;
		add(lblShopStock, gbc_lblShopStock);
		
		playerFoodStock = new JLabel("1");
		playerFoodStock.setHorizontalAlignment(SwingConstants.CENTER);
		playerFoodStock.setBackground(new Color(238, 232, 170));
		playerFoodStock.setOpaque(true);
		GridBagConstraints gbc_playerFoodStock = new GridBagConstraints();
		gbc_playerFoodStock.fill = GridBagConstraints.BOTH;
		gbc_playerFoodStock.insets = new Insets(0, 0, 0, 5);
		gbc_playerFoodStock.gridx = 1;
		gbc_playerFoodStock.gridy = 6;
		add(playerFoodStock, gbc_playerFoodStock);
		
		foodTF = new JTextField();
		GridBagConstraints gbc_foodTF = new GridBagConstraints();
		gbc_foodTF.insets = new Insets(0, 0, 0, 5);
		gbc_foodTF.gridx = 2;
		gbc_foodTF.gridy = 6;
		add(foodTF, gbc_foodTF);
		foodTF.setColumns(3);
		
		foodLabel = new JLabel("A pound of food");
		foodLabel.setBackground(new Color(238, 232, 170));
		foodLabel.setOpaque(true);
		GridBagConstraints gbc_foodLabel = new GridBagConstraints();
		gbc_foodLabel.fill = GridBagConstraints.BOTH;
		gbc_foodLabel.insets = new Insets(0, 0, 0, 5);
		gbc_foodLabel.gridx = 3;
		gbc_foodLabel.gridy = 6;
		add(foodLabel, gbc_foodLabel);
		
		foodPriceLabel = new JLabel("$");
		foodPriceLabel.setHorizontalAlignment(SwingConstants.CENTER);
		foodPriceLabel.setBackground(new Color(238, 232, 170));
		foodPriceLabel.setOpaque(true);
		GridBagConstraints gbc_foodPriceLabel = new GridBagConstraints();
		gbc_foodPriceLabel.fill = GridBagConstraints.BOTH;
		gbc_foodPriceLabel.insets = new Insets(0, 0, 0, 5);
		gbc_foodPriceLabel.gridx = 4;
		gbc_foodPriceLabel.gridy = 6;
		add(foodPriceLabel, gbc_foodPriceLabel);
		
		foodWeightLabel = new JLabel("lb");
		foodWeightLabel.setHorizontalAlignment(SwingConstants.CENTER);
		foodWeightLabel.setBackground(new Color(238, 232, 170));
		foodWeightLabel.setOpaque(true);
		GridBagConstraints gbc_foodWeightLabel = new GridBagConstraints();
		gbc_foodWeightLabel.fill = GridBagConstraints.BOTH;
		gbc_foodWeightLabel.insets = new Insets(0, 0, 0, 5);
		gbc_foodWeightLabel.gridx = 5;
		gbc_foodWeightLabel.gridy = 6;
		add(foodWeightLabel, gbc_foodWeightLabel);
		
		shopFoodStock = new JLabel("1");
		shopFoodStock.setHorizontalAlignment(SwingConstants.CENTER);
		shopFoodStock.setBackground(new Color(238, 232, 170));
		shopFoodStock.setOpaque(true);
		GridBagConstraints gbc_shopFoodStock = new GridBagConstraints();
		gbc_shopFoodStock.fill = GridBagConstraints.BOTH;
		gbc_shopFoodStock.insets = new Insets(0, 0, 0, 5);
		gbc_shopFoodStock.gridx = 6;
		gbc_shopFoodStock.gridy = 6;
		add(shopFoodStock, gbc_shopFoodStock);
		
		playerOxenStock = new JLabel("1");
		playerOxenStock.setHorizontalAlignment(SwingConstants.CENTER);
		playerOxenStock.setBackground(new Color(238, 232, 170));
		playerOxenStock.setOpaque(true);
		GridBagConstraints gbc_playerOxenStock = new GridBagConstraints();
		gbc_playerOxenStock.fill = GridBagConstraints.BOTH;
		gbc_playerOxenStock.insets = new Insets(0, 0, 0, 5);
		gbc_playerOxenStock.gridx = 1;
		gbc_playerOxenStock.gridy = 7;
		add(playerOxenStock, gbc_playerOxenStock);
		
		oxenTF = new JTextField();
		GridBagConstraints gbc_oxenTF = new GridBagConstraints();
		gbc_oxenTF.insets = new Insets(0, 0, 5, 5);
		gbc_oxenTF.gridx = 2;
		gbc_oxenTF.gridy = 7;
		add(oxenTF, gbc_oxenTF);
		oxenTF.setColumns(3);
		
		oxenLabel = new JLabel("A yoke of oxen");
		oxenLabel.setBackground(new Color(238, 232, 170));
		oxenLabel.setOpaque(true);
		GridBagConstraints gbc_oxenLabel = new GridBagConstraints();
		gbc_oxenLabel.fill = GridBagConstraints.BOTH;
		gbc_oxenLabel.insets = new Insets(0, 0, 0, 5);
		gbc_oxenLabel.gridx = 3;
		gbc_oxenLabel.gridy = 7;
		add(oxenLabel, gbc_oxenLabel);
		
		oxenPriceLabel = new JLabel("$");
		oxenPriceLabel.setHorizontalAlignment(SwingConstants.CENTER);
		oxenPriceLabel.setBackground(new Color(238, 232, 170));
		oxenPriceLabel.setOpaque(true);
		GridBagConstraints gbc_oxenPriceLabel = new GridBagConstraints();
		gbc_oxenPriceLabel.fill = GridBagConstraints.BOTH;
		gbc_oxenPriceLabel.insets = new Insets(0, 0, 0, 5);
		gbc_oxenPriceLabel.gridx = 4;
		gbc_oxenPriceLabel.gridy = 7;
		add(oxenPriceLabel, gbc_oxenPriceLabel);
		
		oxenWeightLabel = new JLabel("lb");
		oxenWeightLabel.setHorizontalAlignment(SwingConstants.CENTER);
		oxenWeightLabel.setBackground(new Color(238, 232, 170));
		oxenWeightLabel.setOpaque(true);
		GridBagConstraints gbc_oxenWeightLabel = new GridBagConstraints();
		gbc_oxenWeightLabel.fill = GridBagConstraints.BOTH;
		gbc_oxenWeightLabel.insets = new Insets(0, 0, 0, 5);
		gbc_oxenWeightLabel.gridx = 5;
		gbc_oxenWeightLabel.gridy = 7;
		add(oxenWeightLabel, gbc_oxenWeightLabel);
		
		shopOxenStock = new JLabel("1");
		shopOxenStock.setHorizontalAlignment(SwingConstants.CENTER);
		shopOxenStock.setBackground(new Color(238, 232, 170));
		shopOxenStock.setOpaque(true);
		GridBagConstraints gbc_shopOxenStock = new GridBagConstraints();
		gbc_shopOxenStock.fill = GridBagConstraints.BOTH;
		gbc_shopOxenStock.insets = new Insets(0, 0, 0, 5);
		gbc_shopOxenStock.gridx = 6;
		gbc_shopOxenStock.gridy = 7;
		add(shopOxenStock, gbc_shopOxenStock);
		
		playerClothingStock = new JLabel("1");
		playerClothingStock.setHorizontalAlignment(SwingConstants.CENTER);
		playerClothingStock.setBackground(new Color(238, 232, 170));
		playerClothingStock.setOpaque(true);
		GridBagConstraints gbc_playerClothingStock = new GridBagConstraints();
		gbc_playerClothingStock.fill = GridBagConstraints.BOTH;
		gbc_playerClothingStock.insets = new Insets(0, 0, 0, 5);
		gbc_playerClothingStock.gridx = 1;
		gbc_playerClothingStock.gridy = 8;
		add(playerClothingStock, gbc_playerClothingStock);
		
		clothingTF = new JTextField();
		GridBagConstraints gbc_clothingTF = new GridBagConstraints();
		gbc_clothingTF.insets = new Insets(0, 0, 5, 5);
		gbc_clothingTF.gridx = 2;
		gbc_clothingTF.gridy = 8;
		add(clothingTF, gbc_clothingTF);
		clothingTF.setColumns(3);
		
		clothingLabel = new JLabel("A set of clothing");
		clothingLabel.setBackground(new Color(238, 232, 170));
		clothingLabel.setOpaque(true);
		GridBagConstraints gbc_clothingLabel = new GridBagConstraints();
		gbc_clothingLabel.fill = GridBagConstraints.BOTH;
		gbc_clothingLabel.insets = new Insets(0, 0, 0, 5);
		gbc_clothingLabel.gridx = 3;
		gbc_clothingLabel.gridy = 8;
		add(clothingLabel, gbc_clothingLabel);
		
		clothingPriceLabel = new JLabel("$");
		clothingPriceLabel.setHorizontalAlignment(SwingConstants.CENTER);
		clothingPriceLabel.setBackground(new Color(238, 232, 170));
		clothingPriceLabel.setOpaque(true);
		GridBagConstraints gbc_clothingPriceLabel = new GridBagConstraints();
		gbc_clothingPriceLabel.fill = GridBagConstraints.BOTH;
		gbc_clothingPriceLabel.insets = new Insets(0, 0, 0, 5);
		gbc_clothingPriceLabel.gridx = 4;
		gbc_clothingPriceLabel.gridy = 8;
		add(clothingPriceLabel, gbc_clothingPriceLabel);
		
		clothingWeightLabel = new JLabel("lb");
		clothingWeightLabel.setHorizontalAlignment(SwingConstants.CENTER);
		clothingWeightLabel.setBackground(new Color(238, 232, 170));
		clothingWeightLabel.setOpaque(true);
		GridBagConstraints gbc_clothingWeightLabel = new GridBagConstraints();
		gbc_clothingWeightLabel.fill = GridBagConstraints.BOTH;
		gbc_clothingWeightLabel.insets = new Insets(0, 0, 0, 5);
		gbc_clothingWeightLabel.gridx = 5;
		gbc_clothingWeightLabel.gridy = 8;
		add(clothingWeightLabel, gbc_clothingWeightLabel);
		
		shopClothingStock = new JLabel("1");
		shopClothingStock.setHorizontalAlignment(SwingConstants.CENTER);
		shopClothingStock.setBackground(new Color(238, 232, 170));
		shopClothingStock.setOpaque(true);
		GridBagConstraints gbc_shopClothingStock = new GridBagConstraints();
		gbc_shopClothingStock.fill = GridBagConstraints.BOTH;
		gbc_shopClothingStock.insets = new Insets(0, 0, 0, 5);
		gbc_shopClothingStock.gridx = 6;
		gbc_shopClothingStock.gridy = 8;
		add(shopClothingStock, gbc_shopClothingStock);
		
		playerAmmoStock = new JLabel("1");
		playerAmmoStock.setHorizontalAlignment(SwingConstants.CENTER);
		playerAmmoStock.setBackground(new Color(238, 232, 170));
		playerAmmoStock.setOpaque(true);
		GridBagConstraints gbc_playerAmmoStock = new GridBagConstraints();
		gbc_playerAmmoStock.fill = GridBagConstraints.BOTH;
		gbc_playerAmmoStock.insets = new Insets(0, 0, 0, 5);
		gbc_playerAmmoStock.gridx = 1;
		gbc_playerAmmoStock.gridy = 9;
		add(playerAmmoStock, gbc_playerAmmoStock);
		
		roundsTF = new JTextField();
		GridBagConstraints gbc_roundsTF = new GridBagConstraints();
		gbc_roundsTF.insets = new Insets(0, 0, 5, 5);
		gbc_roundsTF.gridx = 2;
		gbc_roundsTF.gridy = 9;
		add(roundsTF, gbc_roundsTF);
		roundsTF.setColumns(3);
		
		ammoLabel = new JLabel("A box of 20 bullets");
		ammoLabel.setBackground(new Color(238, 232, 170));
		ammoLabel.setOpaque(true);
		GridBagConstraints gbc_ammoLabel = new GridBagConstraints();
		gbc_ammoLabel.fill = GridBagConstraints.BOTH;
		gbc_ammoLabel.insets = new Insets(0, 0, 0, 5);
		gbc_ammoLabel.gridx = 3;
		gbc_ammoLabel.gridy = 9;
		add(ammoLabel, gbc_ammoLabel);
		
		ammoPriceLabel = new JLabel("$");
		ammoPriceLabel.setHorizontalAlignment(SwingConstants.CENTER);
		ammoPriceLabel.setBackground(new Color(238, 232, 170));
		ammoPriceLabel.setOpaque(true);
		GridBagConstraints gbc_ammoPriceLabel = new GridBagConstraints();
		gbc_ammoPriceLabel.fill = GridBagConstraints.BOTH;
		gbc_ammoPriceLabel.insets = new Insets(0, 0, 0, 5);
		gbc_ammoPriceLabel.gridx = 4;
		gbc_ammoPriceLabel.gridy = 9;
		add(ammoPriceLabel, gbc_ammoPriceLabel);
		
		ammoWeightLabel = new JLabel("lb");
		ammoWeightLabel.setHorizontalAlignment(SwingConstants.CENTER);
		ammoWeightLabel.setBackground(new Color(238, 232, 170));
		ammoWeightLabel.setOpaque(true);
		GridBagConstraints gbc_ammoWeightLabel = new GridBagConstraints();
		gbc_ammoWeightLabel.fill = GridBagConstraints.BOTH;
		gbc_ammoWeightLabel.insets = new Insets(0, 0, 0, 5);
		gbc_ammoWeightLabel.gridx = 5;
		gbc_ammoWeightLabel.gridy = 9;
		add(ammoWeightLabel, gbc_ammoWeightLabel);
	
		shopAmmoStock = new JLabel("1");
		shopAmmoStock.setHorizontalAlignment(SwingConstants.CENTER);
		shopAmmoStock.setBackground(new Color(238, 232, 170));
		shopAmmoStock.setOpaque(true);
		GridBagConstraints gbc_shopAmmoStock = new GridBagConstraints();
		gbc_shopAmmoStock.fill = GridBagConstraints.BOTH;
		gbc_shopAmmoStock.insets = new Insets(0, 0, 0, 5);
		gbc_shopAmmoStock.gridx = 6;
		gbc_shopAmmoStock.gridy = 9;
		add(shopAmmoStock, gbc_shopAmmoStock);
		
		playerWheelStock = new JLabel("1");
		playerWheelStock.setHorizontalAlignment(SwingConstants.CENTER);
		playerWheelStock.setOpaque(true);
		playerWheelStock.setBackground(new Color(238, 232, 170));
		GridBagConstraints gbc_playerWheelStock = new GridBagConstraints();
		gbc_playerWheelStock.fill = GridBagConstraints.BOTH;
		gbc_playerWheelStock.insets = new Insets(0, 0, 0, 5);
		gbc_playerWheelStock.gridx = 1;
		gbc_playerWheelStock.gridy = 10;
		add(playerWheelStock, gbc_playerWheelStock);
		
		wheelTF = new JTextField();
		GridBagConstraints gbc_wheelTF = new GridBagConstraints();
		gbc_wheelTF.insets = new Insets(0, 0, 5, 5);
		gbc_wheelTF.gridx = 2;
		gbc_wheelTF.gridy = 10;
		add(wheelTF, gbc_wheelTF);
		wheelTF.setColumns(3);
		
		wheelLabel = new JLabel("A wagon wheel");
		wheelLabel.setBackground(new Color(238, 232, 170));
		wheelLabel.setOpaque(true);
		GridBagConstraints gbc_wheelLabel = new GridBagConstraints();
		gbc_wheelLabel.fill = GridBagConstraints.BOTH;
		gbc_wheelLabel.insets = new Insets(0, 0, 0, 5);
		gbc_wheelLabel.gridx = 3;
		gbc_wheelLabel.gridy = 10;
		add(wheelLabel, gbc_wheelLabel);
		
		wheelPriceLabel = new JLabel("$");
		wheelPriceLabel.setHorizontalAlignment(SwingConstants.CENTER);
		wheelPriceLabel.setBackground(new Color(238, 232, 170));
		wheelPriceLabel.setOpaque(true);
		GridBagConstraints gbc_wheelPriceLabel = new GridBagConstraints();
		gbc_wheelPriceLabel.fill = GridBagConstraints.BOTH;
		gbc_wheelPriceLabel.insets = new Insets(0, 0, 0, 5);
		gbc_wheelPriceLabel.gridx = 4;
		gbc_wheelPriceLabel.gridy = 10;
		add(wheelPriceLabel, gbc_wheelPriceLabel);
		
		wheelWeightLabel = new JLabel("lb");
		wheelWeightLabel.setHorizontalAlignment(SwingConstants.CENTER);
		wheelWeightLabel.setBackground(new Color(238, 232, 170));
		wheelWeightLabel.setOpaque(true);
		GridBagConstraints gbc_wheelWeightLabel = new GridBagConstraints();
		gbc_wheelWeightLabel.fill = GridBagConstraints.BOTH;
		gbc_wheelWeightLabel.insets = new Insets(0, 0, 0, 5);
		gbc_wheelWeightLabel.gridx = 5;
		gbc_wheelWeightLabel.gridy = 10;
		add(wheelWeightLabel, gbc_wheelWeightLabel);
		
		shopWheelStock = new JLabel("1");
		shopWheelStock.setHorizontalAlignment(SwingConstants.CENTER);
		shopWheelStock.setBackground(new Color(238, 232, 170));
		shopWheelStock.setOpaque(true);
		GridBagConstraints gbc_shopWheelStock = new GridBagConstraints();
		gbc_shopWheelStock.fill = GridBagConstraints.BOTH;
		gbc_shopWheelStock.insets = new Insets(0, 0, 0, 5);
		gbc_shopWheelStock.gridx = 6;
		gbc_shopWheelStock.gridy = 10;
		add(shopWheelStock, gbc_shopWheelStock);
		
		playerAxleStock = new JLabel("1");
		playerAxleStock.setHorizontalAlignment(SwingConstants.CENTER);
		playerAxleStock.setOpaque(true);
		playerAxleStock.setBackground(new Color(238, 232, 170));
		GridBagConstraints gbc_playerAxleStock = new GridBagConstraints();
		gbc_playerAxleStock.fill = GridBagConstraints.BOTH;
		gbc_playerAxleStock.insets = new Insets(0, 0, 0, 5);
		gbc_playerAxleStock.gridx = 1;
		gbc_playerAxleStock.gridy = 11;
		add(playerAxleStock, gbc_playerAxleStock);
		
		axleTF = new JTextField();
		GridBagConstraints gbc_axleTF = new GridBagConstraints();
		gbc_axleTF.insets = new Insets(0, 0, 5, 5);
		gbc_axleTF.gridx = 2;
		gbc_axleTF.gridy = 11;
		add(axleTF, gbc_axleTF);
		axleTF.setColumns(3);
		
		axleLabel = new JLabel("A wagon axle");
		axleLabel.setBackground(new Color(238, 232, 170));
		axleLabel.setOpaque(true);
		GridBagConstraints gbc_axleLabel = new GridBagConstraints();
		gbc_axleLabel.fill = GridBagConstraints.BOTH;
		gbc_axleLabel.insets = new Insets(0, 0, 0, 5);
		gbc_axleLabel.gridx = 3;
		gbc_axleLabel.gridy = 11;
		add(axleLabel, gbc_axleLabel);
		
		axlePriceLabel = new JLabel("$");
		axlePriceLabel.setHorizontalAlignment(SwingConstants.CENTER);
		axlePriceLabel.setBackground(new Color(238, 232, 170));
		axlePriceLabel.setOpaque(true);
		GridBagConstraints gbc_axlePriceLabel = new GridBagConstraints();
		gbc_axlePriceLabel.fill = GridBagConstraints.BOTH;
		gbc_axlePriceLabel.insets = new Insets(0, 0, 0, 5);
		gbc_axlePriceLabel.gridx = 4;
		gbc_axlePriceLabel.gridy = 11;
		add(axlePriceLabel, gbc_axlePriceLabel);
		
		axleWeightLabel = new JLabel("lb");
		axleWeightLabel.setHorizontalAlignment(SwingConstants.CENTER);
		axleWeightLabel.setBackground(new Color(238, 232, 170));
		axleWeightLabel.setOpaque(true);
		GridBagConstraints gbc_axleWeightLabel = new GridBagConstraints();
		gbc_axleWeightLabel.fill = GridBagConstraints.BOTH;
		gbc_axleWeightLabel.insets = new Insets(0, 0, 0, 5);
		gbc_axleWeightLabel.gridx = 5;
		gbc_axleWeightLabel.gridy = 11;
		add(axleWeightLabel, gbc_axleWeightLabel);
		
		shopAxleStock = new JLabel("1");
		shopAxleStock.setHorizontalAlignment(SwingConstants.CENTER);
		shopAxleStock.setBackground(new Color(238, 232, 170));
		shopAxleStock.setOpaque(true);
		GridBagConstraints gbc_shopAxleStock = new GridBagConstraints();
		gbc_shopAxleStock.fill = GridBagConstraints.BOTH;
		gbc_shopAxleStock.insets = new Insets(0, 0, 0, 5);
		gbc_shopAxleStock.gridx = 6;
		gbc_shopAxleStock.gridy = 11;
		add(shopAxleStock, gbc_shopAxleStock);
		
		playerTongueStock = new JLabel("1");
		playerTongueStock.setHorizontalAlignment(SwingConstants.CENTER);
		playerTongueStock.setOpaque(true);
		playerTongueStock.setBackground(new Color(238, 232, 170));
		GridBagConstraints gbc_playerTongueStock = new GridBagConstraints();
		gbc_playerTongueStock.fill = GridBagConstraints.BOTH;
		gbc_playerTongueStock.insets = new Insets(0, 0, 0, 5);
		gbc_playerTongueStock.gridx = 1;
		gbc_playerTongueStock.gridy = 12;
		add(playerTongueStock, gbc_playerTongueStock);
		
		tongueTF = new JTextField();
		GridBagConstraints gbc_tongueTF = new GridBagConstraints();
		gbc_tongueTF.insets = new Insets(0, 0, 5, 5);
		gbc_tongueTF.gridx = 2;
		gbc_tongueTF.gridy = 12;
		add(tongueTF, gbc_tongueTF);
		tongueTF.setColumns(3);
		
		tongueLabel = new JLabel("A wagon tongue");
		tongueLabel.setBackground(new Color(238, 232, 170));
		tongueLabel.setOpaque(true);
		GridBagConstraints gbc_tongueLabel = new GridBagConstraints();
		gbc_tongueLabel.fill = GridBagConstraints.BOTH;
		gbc_tongueLabel.insets = new Insets(0, 0, 0, 5);
		gbc_tongueLabel.gridx = 3;
		gbc_tongueLabel.gridy = 12;
		add(tongueLabel, gbc_tongueLabel);
		
		tonguePriceLabel = new JLabel("$");
		tonguePriceLabel.setHorizontalAlignment(SwingConstants.CENTER);
		tonguePriceLabel.setBackground(new Color(238, 232, 170));
		tonguePriceLabel.setOpaque(true);
		GridBagConstraints gbc_tonguePriceLabel = new GridBagConstraints();
		gbc_tonguePriceLabel.fill = GridBagConstraints.BOTH;
		gbc_tonguePriceLabel.insets = new Insets(0, 0, 0, 5);
		gbc_tonguePriceLabel.gridx = 4;
		gbc_tonguePriceLabel.gridy = 12;
		add(tonguePriceLabel, gbc_tonguePriceLabel);
		
		tongueWeightLabel = new JLabel("lb");
		tongueWeightLabel.setHorizontalAlignment(SwingConstants.CENTER);
		tongueWeightLabel.setBackground(new Color(238, 232, 170));
		tongueWeightLabel.setOpaque(true);
		GridBagConstraints gbc_tongueWeightLabel = new GridBagConstraints();
		gbc_tongueWeightLabel.fill = GridBagConstraints.BOTH;
		gbc_tongueWeightLabel.insets = new Insets(0, 0, 0, 5);
		gbc_tongueWeightLabel.gridx = 5;
		gbc_tongueWeightLabel.gridy = 12;
		add(tongueWeightLabel, gbc_tongueWeightLabel);
		
		shopTongueStock = new JLabel("1");
		shopTongueStock.setHorizontalAlignment(SwingConstants.CENTER);
		shopTongueStock.setBackground(new Color(238, 232, 170));
		shopTongueStock.setOpaque(true);
		GridBagConstraints gbc_shopTongueStock = new GridBagConstraints();
		gbc_shopTongueStock.fill = GridBagConstraints.BOTH;
		gbc_shopTongueStock.insets = new Insets(0, 0, 0, 5);
		gbc_shopTongueStock.gridx = 6;
		gbc_shopTongueStock.gridy = 12;
		add(shopTongueStock, gbc_shopTongueStock);
		
		purchaseButton = new JLabel("");
		purchaseButton.addMouseListener(this);
		
		purchaseButton.setIcon(new ImageIcon(ShopPanel.class.getResource("/edu/gatech/cs2340/OregonTrail/Images/purchase.png")));
		GridBagConstraints gbc_purchaseButton = new GridBagConstraints();
		gbc_purchaseButton.gridwidth = 4;
		gbc_purchaseButton.insets = new Insets(0, 0, 0, 5);
		gbc_purchaseButton.gridx = 0;
		gbc_purchaseButton.gridy = 14;
		add(purchaseButton, gbc_purchaseButton);
		
		finishButton = new JLabel("");
		finishButton.addMouseListener(this);
		
		finishButton.setIcon(new ImageIcon(ShopPanel.class.getResource("/edu/gatech/cs2340/OregonTrail/Images/finish.png")));
		GridBagConstraints gbc_finishButton = new GridBagConstraints();
		gbc_finishButton.gridwidth = 4;
		gbc_finishButton.gridx = 4;
		gbc_finishButton.gridy = 14;
		add(finishButton, gbc_finishButton);
		
		shop = null;
	}

	@Override
	public void guiActionPerformed(GUIEvent e) {
		if(e.getClass() == AtShopEvent.class){
			shop = (Shop) e.getSource();
			titleLabel.setText("Welcome to the " + shop.getLocationName() + " shop!");
			currMoneyLabel.setText("Current Funds: $" + ((AtShopEvent) e).getCurrentFunds());
			currWeightLabel.setText("Current Weight: " + ((AtShopEvent) e).getCurrentWeight() + " / 3500");
			Map<Item, Integer> prices = ((AtShopEvent) e).getPrices();
			Iterator<Item> it = prices.keySet().iterator();
			Item nextItem = null;
			while(it.hasNext()){
				nextItem = it.next();
				if(nextItem.getItemName().compareToIgnoreCase("Food") == 0){
					foodPriceLabel.setText("$" + prices.get(nextItem));
					foodWeightLabel.setText(nextItem.getWeight() +" lbs");
				} else if(nextItem.getItemName().compareToIgnoreCase("An ox") == 0){
					oxenPriceLabel.setText("$" + prices.get(nextItem));
					oxenWeightLabel.setText(nextItem.getWeight() +" lbs");
				} else if(nextItem.getItemName().compareToIgnoreCase("A set of clothing") == 0){
					clothingPriceLabel.setText("$" + prices.get(nextItem));
					clothingWeightLabel.setText(nextItem.getWeight() +" lbs");
				} else if(nextItem.getItemName().compareToIgnoreCase("Ammunition, a box of 20 rounds") == 0){
					ammoPriceLabel.setText("$" + prices.get(nextItem));
					ammoWeightLabel.setText(nextItem.getWeight() +" lbs");
				} else if(nextItem.getItemName().compareToIgnoreCase("A wagon wheel") == 0){
					wheelPriceLabel.setText("$" + prices.get(nextItem));
					wheelWeightLabel.setText(nextItem.getWeight() +" lbs");
				} else if(nextItem.getItemName().compareToIgnoreCase("A wagon axle") == 0){
					axlePriceLabel.setText("$" + prices.get(nextItem));
					axleWeightLabel.setText(nextItem.getWeight() +" lbs");
				} else if(nextItem.getItemName().compareToIgnoreCase("A wagon tongue") == 0){
					tonguePriceLabel.setText("$" + prices.get(nextItem));
					tongueWeightLabel.setText(nextItem.getWeight() +" lbs");
				}
			}
			
			Map<Item, Integer> playerStock = ((AtShopEvent) e).getPlayerStock();
			it = playerStock.keySet().iterator();
			nextItem = null;
			while(it.hasNext()){
				nextItem = it.next();
				if(nextItem.getItemName().compareToIgnoreCase("Food") == 0){
					playerFoodStock.setText("" + playerStock.get(nextItem));
				} else if(nextItem.getItemName().compareToIgnoreCase("An ox") == 0){
					playerOxenStock.setText("" + playerStock.get(nextItem));
				} else if(nextItem.getItemName().compareToIgnoreCase("A set of clothing") == 0){
					playerClothingStock.setText("" + playerStock.get(nextItem));
				} else if(nextItem.getItemName().compareToIgnoreCase("Ammunition, a box of 20 rounds") == 0){
					playerAmmoStock.setText("" + playerStock.get(nextItem));
				} else if(nextItem.getItemName().compareToIgnoreCase("A wagon wheel") == 0){
					playerWheelStock.setText("" + playerStock.get(nextItem));
				} else if(nextItem.getItemName().compareToIgnoreCase("A wagon axle") == 0){
					playerAxleStock.setText("" + playerStock.get(nextItem));
				} else if(nextItem.getItemName().compareToIgnoreCase("A wagon tongue") == 0){
					playerTongueStock.setText("" + playerStock.get(nextItem));
				}
			}
			
			it = shop.getShopInventory().keySet().iterator();
			nextItem = null;
			while(it.hasNext()){
				nextItem = it.next();
				if(nextItem.getItemName().compareToIgnoreCase("Food") == 0){
					shopFoodStock.setText("" + shop.getShopInventory().get(nextItem));
				} else if(nextItem.getItemName().compareToIgnoreCase("An ox") == 0){
					shopOxenStock.setText("" + shop.getShopInventory().get(nextItem));
				} else if(nextItem.getItemName().compareToIgnoreCase("A set of clothing") == 0){
					shopClothingStock.setText("" + shop.getShopInventory().get(nextItem));
				} else if(nextItem.getItemName().compareToIgnoreCase("Ammunition, a box of 20 rounds") == 0){
					shopAmmoStock.setText("" + shop.getShopInventory().get(nextItem));
				} else if(nextItem.getItemName().compareToIgnoreCase("A wagon wheel") == 0){
					shopWheelStock.setText("" + shop.getShopInventory().get(nextItem));
				} else if(nextItem.getItemName().compareToIgnoreCase("A wagon axle") == 0){
					shopAxleStock.setText("" + shop.getShopInventory().get(nextItem));
				} else if(nextItem.getItemName().compareToIgnoreCase("A wagon tongue") == 0){
					shopTongueStock.setText("" + shop.getShopInventory().get(nextItem));
				}
				/* because showing Integer.MAX_VALUE as your stock is ugly...
				this is slightly hacky, but if the string length is > 5 (meaning we have
				100,000 or more of an item), then for all intents and purposes we have
				infinite amounts of that item. */
				if (shopFoodStock.getText().length() > 5){
					shopFoodStock.setText("LOTS");
				}
				if (shopOxenStock.getText().length() > 5){
					shopOxenStock.setText("LOTS");
				}
				if (shopClothingStock.getText().length() > 5){
					shopClothingStock.setText("LOTS");
				}
				if (shopAmmoStock.getText().length() > 5){
					shopAmmoStock.setText("LOTS");
				}
				if (shopWheelStock.getText().length() > 5){
					shopWheelStock.setText("LOTS");
				}
				if (shopAxleStock.getText().length() > 5){
					shopAxleStock.setText("LOTS");
				}
				if (shopTongueStock.getText().length() > 5){
					shopTongueStock.setText("LOTS");
				}
			}
			parent.showShop();
		}
	}
	

	public void mouseClicked(MouseEvent e) {
		if(e.getSource() == purchaseButton){
			Map<Item,Integer> toPurchase = new HashMap<Item, Integer>();
			Iterator<Item> it = shop.getShopInventory().keySet().iterator();
			Item nextItem = null;
			int amt;
			while(it.hasNext()){
				nextItem = it.next();
				if(nextItem.getItemName().equalsIgnoreCase("Food")){
					try{amt = Integer.parseInt(foodTF.getText().replaceAll("[^0-9]",""));}
					catch(Exception err){amt = 0;}
					toPurchase.put(nextItem, amt);
				} else if(nextItem.getItemName().equalsIgnoreCase("An ox")){
					try{amt = Integer.parseInt(oxenTF.getText().replaceAll("[^0-9]","")) * 2;}
					catch(Exception err){amt = 0;}
					toPurchase.put(nextItem, amt);
				} else if(nextItem.getItemName().equalsIgnoreCase("A set of clothing")){
					try{amt = Integer.parseInt(clothingTF.getText().replaceAll("[^0-9]",""));}
					catch(Exception err){amt = 0;}
					toPurchase.put(nextItem, amt);
				} else if(nextItem.getItemName().equalsIgnoreCase("Ammunition, a box of 20 rounds")){
					try{amt = Integer.parseInt(roundsTF.getText().replaceAll("[^0-9]",""));}
					catch(Exception err){amt = 0;}
					toPurchase.put(nextItem, amt);
				} else if(nextItem.getItemName().equalsIgnoreCase("A wagon wheel")){
					try{amt = Integer.parseInt(wheelTF.getText().replaceAll("[^0-9]",""));}
					catch(Exception err){amt = 0;}
					toPurchase.put(nextItem, amt);
				} else if(nextItem.getItemName().equalsIgnoreCase("A wagon axle")){
					try{amt = Integer.parseInt(axleTF.getText().replaceAll("[^0-9]",""));}
					catch(Exception err){amt = 0;}
					toPurchase.put(nextItem, amt);
				} else if(nextItem.getItemName().equalsIgnoreCase("A wagon tongue")){
					try{amt = Integer.parseInt(tongueTF.getText().replaceAll("[^0-9]",""));}
					catch(Exception err){amt = 0;}
					toPurchase.put(nextItem, amt);
				}
			}
			
			int purchaseCost = 0;
			int purchaseWeight = 0;
			Iterator<Item> purchaseIterator = toPurchase.keySet().iterator();
			assert toPurchase.size() < 100;
			Item itemToPurchase = null;
			while (purchaseIterator.hasNext())
			{
				itemToPurchase = purchaseIterator.next();
				purchaseCost += itemToPurchase.getBaseCost() * 
						toPurchase.get(itemToPurchase); // Multiply by region multiplier here?
				purchaseWeight += itemToPurchase.getWeight() * toPurchase.get(itemToPurchase);
			}
			String s = currMoneyLabel.getText();			
			// this is ugly, but it's not too bad - it splits the money label around " ", takes the 3rd
			// chunk of that (following the colon) and parses everything after the dollar sign.
			// assumes currMoneyLabel looks something like: "current funds: $200"
			int currentFunds = Integer.parseInt(s.split(" ")[2].substring(1, s.split(" ")[2].length()));
			// to get the substring containing the weight value, take everything after ": "...
			// assumes currWeightLabel looks something like: "current weight: 1000 / 3500"
			String weightString = currWeightLabel.getText().split(": ")[1];
			// ...then from there, take everything before " /".
			weightString = weightString.split(" /")[0];
			int currentWeight = Integer.parseInt(weightString);
			if (currentFunds < purchaseCost) JOptionPane.showMessageDialog(null, "Insufficient funds!");
			else if (currentWeight + purchaseWeight > 3500) JOptionPane.showMessageDialog(null, "I can't carry that!");
			else if (!shop.inStock(toPurchase)) JOptionPane.showMessageDialog(null, "Those items are not in stock");
			else if (Integer.parseInt(playerOxenStock.getText()) <= 0 && (currentFunds - purchaseCost) < 40) JOptionPane.showMessageDialog(null, "You must buy at least one yoke of oxen.");
			else {
				communicator.ThrowActorEvent(new PlayerInventoryModifiedEvent(this, toPurchase));
				updateShop(toPurchase);
				currentWeight += purchaseWeight;
				Component[] components = this.getComponents();
				for (int i = 0; i < components.length; i++ ) {
					if(components[i] instanceof JTextField){						   
						   ((JTextField) components[i]).setText("");
					}
				}
			}
			
			// because showing Integer.MAX_VALUE as your stock is ugly
			if (shopFoodStock.getText().length() > 5){
				shopFoodStock.setText("LOTS");
			}
			if (shopOxenStock.getText().length() > 5){
				shopOxenStock.setText("LOTS");
			}
			if (shopClothingStock.getText().length() > 5){
				shopClothingStock.setText("LOTS");
			}
			if (shopAmmoStock.getText().length() > 5){
				shopAmmoStock.setText("LOTS");
			}
			if (shopWheelStock.getText().length() > 5){
				shopWheelStock.setText("LOTS");
			}
			if (shopAxleStock.getText().length() > 5){
				shopAxleStock.setText("LOTS");
			}
			if (shopTongueStock.getText().length() > 5){
				shopTongueStock.setText("LOTS");
			}			
		}
		
		else if(e.getSource() == finishButton){
			if(Integer.parseInt(playerOxenStock.getText()) <= 0){
				JOptionPane.showMessageDialog(null,"You must purchase at least one yoke of oxen.");
			}
			else{
				Component[] components = this.getComponents();
				for (int i = 0; i < components.length; i++ ) {
					if(components[i] instanceof JTextField){						   
						   ((JTextField) components[i]).setText("");
					}
				}
				parent.returnFromShop();
			}
		}
	}
	
	public void updatePlayerInfo(int newFunds, int newWeight, Map<Item, Integer> playerStock){
		currMoneyLabel.setText("Current Funds: $" + newFunds);
		currWeightLabel.setText("Current Weight: " + newWeight + " / 3500");
		
		Iterator<Item>it = playerStock.keySet().iterator();
		Item nextItem = null;
		while(it.hasNext()){
			nextItem = it.next();
			if(nextItem.getItemName().compareToIgnoreCase("Food") == 0){
				playerFoodStock.setText("" + playerStock.get(nextItem));
			} else if(nextItem.getItemName().compareToIgnoreCase("An ox") == 0){
				playerOxenStock.setText("" + playerStock.get(nextItem));
			} else if(nextItem.getItemName().compareToIgnoreCase("A set of clothing") == 0){
				playerClothingStock.setText("" + playerStock.get(nextItem));
			} else if(nextItem.getItemName().compareToIgnoreCase("Ammunition, a box of 20 rounds") == 0){
				playerAmmoStock.setText("" + playerStock.get(nextItem));
			} else if(nextItem.getItemName().compareToIgnoreCase("A wagon wheel") == 0){
				playerWheelStock.setText("" + playerStock.get(nextItem));
			} else if(nextItem.getItemName().compareToIgnoreCase("A wagon axle") == 0){
				playerAxleStock.setText("" + playerStock.get(nextItem));
			} else if(nextItem.getItemName().compareToIgnoreCase("A wagon tongue") == 0){
				playerTongueStock.setText("" + playerStock.get(nextItem));
			}
		}
	}
	
	public void updateShop(Map<Item, Integer> toPurchase){
		Iterator<Item> it = toPurchase.keySet().iterator();
		Item nextItem = null;
		while(it.hasNext()){
			nextItem = it.next();
			shop.getShopInventory().put(nextItem, shop.getShopInventory().get(nextItem) - toPurchase.get(nextItem));
			if(nextItem.getItemName().equalsIgnoreCase("Food")){
				shopFoodStock.setText("" + shop.getShopInventory().get(nextItem));
			} else if(nextItem.getItemName().equalsIgnoreCase("An ox")){
				shopOxenStock.setText("" + shop.getShopInventory().get(nextItem));
			} else if(nextItem.getItemName().equalsIgnoreCase("A set of clothing")){
				shopClothingStock.setText("" + shop.getShopInventory().get(nextItem));
			} else if(nextItem.getItemName().equalsIgnoreCase("Ammunition, a box of 20 rounds")){
				shopAmmoStock.setText("" + shop.getShopInventory().get(nextItem));
			} else if(nextItem.getItemName().equalsIgnoreCase("A wagon wheel")){
				shopWheelStock.setText("" + shop.getShopInventory().get(nextItem));
			} else if(nextItem.getItemName().equalsIgnoreCase("A wagon axle")){
				shopAxleStock.setText("" + shop.getShopInventory().get(nextItem));
			} else if(nextItem.getItemName().equalsIgnoreCase("A wagon tongue")){
				shopTongueStock.setText("" + shop.getShopInventory().get(nextItem));
			}
		}
	}
	
	public void paintComponent(Graphics g) {
	    super.paintComponent(g);

	    // Draw the background image.
	    g.drawImage(backgroundImage, 0, 0, null);
	}

	@Override
	public void mouseEntered(MouseEvent arg0) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void mouseExited(MouseEvent e) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void mousePressed(MouseEvent e) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void mouseReleased(MouseEvent e) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void actionPerformed(ActionEvent arg0) {
		// TODO Auto-generated method stub
		
	}
}

